function loginTip() {
	alert("Login: admin");
}

function passTip() {
	alert("Hasło: 1234");
}

function addEvent(d,m,y){
	var desc = prompt("Podaj opis eventu", "Opis...");
	
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	{
		alert ("Your browser does not support XMLHTTP!");
		return;
	}
	if(desc==null){
		return;
	}
	var url="dbmanager.php?edit=0&desc="+desc+"&d="+d+"&m="+m+"&y="+y;
	xmlhttp.onreadystatechange=stateChangedAddEvent;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function editEvent(id,desc){
var desc = prompt("Podaj opis eventu", desc);
	
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	{
		alert ("Your browser does not support XMLHTTP!");
		return;
	}
	if(desc==null){
		return;
	}
	var url="dbmanager.php?edit=1&desc="+desc+"&id="+id;
	xmlhttp.onreadystatechange=stateChangedAddEvent;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function hoverOn(cell){
	if(cell.className == "calendar") cell.style.backgroundColor = "#FFC125";
	else cell.style.backgroundColor = "#DAA520";
}

function hoverOff(cell){
	if(cell.className == "calendar") cell.style.backgroundColor = "white";
	else if(cell.className == "calendarFull") cell.style.backgroundColor = "#9AFF9A";
	else if(cell.className == "weekendFull") cell.style.backgroundColor = "#7CCD7C";
	else cell.style.backgroundColor = "#FFDAB9";
}

function eventList(day, month, year){
	window.location = "?s=events&d=" + day + "&m=" + month + "&y=" + year;
}

var xmlhttp

function getCalendar(){
	alert("Test");
}

function getCalendar(month, year)
{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	{
		alert ("Your browser does not support XMLHTTP!");
		return;
	}
	var url="calendar.php?month="+month+"&year="+year;
	xmlhttp.onreadystatechange=stateChanged;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function stateChanged()
{
	if (xmlhttp.readyState==4)
	{
		document.getElementById("calendar").innerHTML=xmlhttp.responseText;
	}
}

function stateChangedAddEvent()
{
	if (xmlhttp.readyState==4)
	{
		location.reload(true);
	}
}

function GetXmlHttpObject()
{
	if (window.XMLHttpRequest)
	{
		// code for IE7+, Firefox, Chrome, Opera, Safari
		return new XMLHttpRequest();
	}
	if (window.ActiveXObject)
	{
		// code for IE6, IE5
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
	return null;
}